
	/*************************图片上传操作***********************/

                //************************ /图书封面(小)图片上传/
                // 图书封面(小)限制张数为1张
                // 父元素对象
                var goods_mainimg_list = $(".goods_mainimg_list");
                // 限制张数
                var goods_mainimg_number = 0;
        
                var uploader_mainimg = new plupload.Uploader({
                    browse_button: "hidden_imgmain",
                    url: uploadurl,
                    filters: {
                        mime_types: [ //只允许上传图片
                            {
                                title: 'Image files',
                                extensions: 'jpg,jpeg,png'
                            }
                        ],
                        max_file_size: '2560kb', //最大只能上传2Mb的文件
                        //prevent_duplicates : true //不允许选取重复文件
                    },
                    multipart_params: { //附加参数
                        type: 1
                    },
                    unique_names: true //上传的文件生成唯一的name值
                });
        
                //初始化
                uploader_mainimg.init();
        
                uploader_mainimg.bind('FilesAdded', function (uploader_mainimg, files) {
                    if (files.length + goods_mainimg_number > 1) {
                        layer.alert("图书封面(小)最多添加1张");
                        uploader_mainimg.splice(goods_mainimg_number);
                        return false;
                    }
                    uploader_mainimg.start(); //开始上传
                });
        
                //绑定单个文件上传完成后事件
                uploader_mainimg.bind('FileUploaded', function (uploader_mainimg, file, res) {
                    // 获取返回的img src值
                    var r = JSON.parse(res.response);
        
                    // 上传实例html
                    goods_lease_singleHtml = '<li class="img_upload_single"><img class="upload_image" data-url=' + r.data.imgUrl + " " +
                        'src=' + "" + r.data.imgPath + r.data.imgUrl +
                        '><a href="javascript:" class="upload_delete" title="删除" data-index="0">x</a></li>';
                    goods_mainimg_add.before($(goods_lease_singleHtml));
                    goods_mainimg_number++;
                    // goods_lease_box.children("li").eq(goods_lease_clcikIndex).find("img").attr('src',r.data.imgPath+r.data.imgUrl);
                });
        
                //绑定所有文件上传完成后事件
                uploader_mainimg.bind('UploadComplete', function (uploader_mainimg, files) {
                    uploader.files.length = 0; //清空上传队列
                });
        
                // 添加图书封面(小)对象
                var goods_mainimg_add = $(".goods_mainimg_add");
        
                goods_mainimg_add.click(function () {
                    if (goods_mainimg_number >= 1) {
                        layer.alert("图书封面(小)最多添加1张");
                        return false;
                    }
                    $("#hidden_imgmain").click();
                })
        
                // 删除图书封面(小)对象
                goods_mainimg_list.on("click", ".upload_delete", function () {
                    $(this).parents("li").remove();
                    goods_mainimg_number--;
                    return false;
                });
                /***********图书封面(小)最终提交前，数据统计赋值*************/
        
                function goods_mainimg_formUpload() {
                    var data = [];
                    var imgList = goods_mainimg_list.find("img");
                    imgList.each(function () {
                        data.push($(this).data("url"));
                    })
                    data.pop();
                    if (data.length == 0) {
                        layer.alert("商品主图不能为空");
                        return false;
                    }
                    $("#id_file_cover").val(data);
                    return true;
                }
        
                //************************ /图书封面(小)图片上传/
        
        
                //************************ /图书详情图片上传/
                // 图书详情限制张数为1张
                // 父元素对象
                var goods_more_list = $(".goods_more_list");
                // 限制张数
                var goods_more_number = 0;
        
                var uploader_more = new plupload.Uploader({
                    browse_button: "hidden_more",
                    url: uploadurl,
                    filters: {
                        mime_types: [ //只允许上传图片
                            {
                                title: 'Image files',
                                extensions: 'jpg,jpeg,png'
                            }
                        ],
                        max_file_size: '2560kb', //最大只能上传2Mb的文件
                        //prevent_duplicates : true //不允许选取重复文件
                    },
                    multipart_params: { //附加参数
                        type: 2
                    },
                    unique_names: true //上传的文件生成唯一的name值
                });
        
                //初始化
                uploader_more.init();
        
                uploader_more.bind('FilesAdded', function (uploader_more, files) {
                    if (files.length + goods_more_number > 5) {
                        layer.alert("图书详情图最多添加5张");
                        uploader_more.splice(goods_more_number);
                        return false;
                    }
                    uploader_more.start(); //开始上传
                });
        
                //绑定单个文件上传完成后事件
                uploader_more.bind('FileUploaded', function (uploader_more, file, res) {
                    // 获取返回的img src值
                    var r = JSON.parse(res.response);
        
                    // 上传实例html
                    goods_lease_singleHtml = '<li class="img_upload_single"><img class="upload_image" data-url=' + r.data.imgUrl + " " +
                        'src=' + "" + r.data.imgPath + r.data.imgUrl +
                        '><a href="javascript:" class="upload_delete" title="删除" data-index="0">x</a></li>';
                    goods_more_add.before($(goods_lease_singleHtml));
        
        
                    goods_more_number++;
                    // goods_lease_box.children("li").eq(goods_lease_clcikIndex).find("img").attr('src',r.data.imgPath+r.data.imgUrl);
                });
        
                //绑定所有文件上传完成后事件
                uploader_more.bind('UploadComplete', function (uploader_more, files) {
                    uploader.files.length = 0; //清空上传队列
                });
        
                // 添加图书详情对象
                var goods_more_add = $(".goods_more_add");
        
                goods_more_add.click(function () {
                    if (goods_more_number >= 5) {
                        layer.alert("图书详情图最多添加5张");
                        return false;
                    }
                    $("#hidden_more").click();
                })
        
                // 删除图书详情对象
                goods_more_list.on("click", ".upload_delete", function () {
                    $(this).parents("li").remove();
                    goods_more_number--;
                    return false;
                });
        
                /***********图书详情最终提交前，数据统计赋值*************/
                function goods_more_formUpload() {
                    var data = [];
                    var imgList = goods_more_list.find("img");
                    imgList.each(function () {
                        data.push($(this).data("url"));
                    })
                    data.pop();
                    //if (data.length == 0) {
                    //    layer.alert("商品详情不能为空");
                    //    return false;
                    //}
                    $("#ipt_book_details_images").val(data);
                    return true;
                }
                //************************ /图书详情图片上传/

                /*************************图片上传操作***********************/